import time
from selenium import webdriver
from selenium.webdriver.common.by import By

d=webdriver.Edge()
# d.get("http://www.baidu.com")
# time.sleep(2)
#
# text=d.find_element(By.ID,"chat-textarea")
# text.send_keys('python')
# text.send_keys('是什么')
# text.send_keys('为什么')
# time.sleep(1)
#
# button=d.find_element('id','chat-submit-button')
# button.click()
# time.sleep(5)


# d.get("http://www.sogou.com")
# time.sleep(2)
#
# d.find_element('name','query').send_keys('selenium')
# d.find_element(By.NAME,'query').send_keys('是什么')
# time.sleep(2)
# button=d.find_element('id','stb')
# button.click()
# time.sleep(5)

# d.get('http://www.baidu.com')
# d.find_element(By.CLASS_NAME,'chat-input-textarea').send_keys('java')
# d.find_element(By.CLASS_NAME,'chat-input-textarea').send_keys('的特点')
# d.find_element('class name','chat-input-textarea.chat-input-scroll-style').send_keys('是什么')
# button=d.find_element('id','chat-submit-button')
# button.click()
# time.sleep(5)

# d.get('http://www.baidu.com')
# aelments=d.find_elements(By.TAG_NAME,'a')
# print(aelments)
# for ae in aelments:
#     print(ae.get_dom_attribute("href"))
#     print(ae.text)
# imgs=d.find_elements('tag name','img')
# for img in imgs:
#     print(img.get_dom_attribute("src"))
#
# d.get('http://www.baidu.com')
# a=d.find_element(By.LINK_TEXT,'网盘')
# print(a.text)
#
# a1 = d.find_element(By.PARTIAL_LINK_TEXT,"40米")
# print(a1.text)
# print(a1.get_dom_attribute("href"))

# d.get("https://www.sogou.com")
# time.sleep(2)
# d.find_element(By.CSS_SELECTOR,'.sec-input').send_keys('选择器')
# d.find_element(By.CSS_SELECTOR,'#query').send_keys('有哪些')
# classstr=d.find_element(By.CSS_SELECTOR,'div').get_dom_attribute('class')
# href1=d.find_element(By.CSS_SELECTOR,'[uigs-id=mid_pinyin]').get_dom_attribute('href')
# href2=d.find_element(By.CSS_SELECTOR,'#QRcode-footer > div.ft-info > a:nth-child(1)').get_dom_attribute('href')
# print(classstr)
# print(href1)
# print(href2)
# time.sleep(5)

d.get("https://www.sogou.com")
time.sleep(2)
a=d.find_element(By.XPATH,'html/body/div/div[2]/div[4]/form/span[1]/input')
a.send_keys('xpath')
b=d.find_element(By.XPATH,'//*[@id="deepseek-entry"]').get_dom_attribute('href')
print(b)
c = d.find_element("xpath","//*[@uigs-id='nav_fanyi']").get_dom_attribute("href")
print(c)

d=d.find_element('xpath','//*[contains(text(),"deep")]')
print(d.get_dom_attribute("target"))

e= d.find_element("xpath","//*[contains(text(),'搜狗')]")
print(e.get_dom_attribute("href"))

f=d.find_element(By.XPATH,'//*[@id="QRcode-footer"]/div[1]/a[1]')
print(e.get_dom_attribute("class"))




